<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="lib/vue.js"></script>
		<script src="lib/vue-resource.js"></script>
	</head>
	<body>
		<div id="app">
			<input type="button" value="get请求" @click="getInfo" /><br />
			<input type="button" value="post请求" @click="postInfo" />
		</div>
		<div id="app1"></div>
		<script>
			var vm = new Vue({
				el: '#app1',
				methods: {
					getInfo() {
						this.$http.jsonp("http://bing.ioliu.cn/v1" //,{credentials:true}, jsonp = 'callback'
						).then(res => {
							console.log(res.body);
						}).catch(e => {
							console.log(e);
						})
					}
				},
				created() {
					this.getInfo();
				}
			})

			var vm = new Vue({
				el: '#app',
				data: {},
				methods: {
					getInfo() {
						this.$http.get('/try/ajax/ajax_info.txt').then(function(result) {
							console.log(result.body)
						})
					},
					postInfo() {
						this.$http.post('/try/ajax/demo_test_post.php', {
							name: "菜鸟教程",
							url: "http://www.runoob.com"
						}, {
							emulateJSON: true
						}).then(result => {
							console.log(result.body)
						})
					}
				}

			})
		</script>
	</body>
</html>
